﻿using Messhall.Framework.Domain.DomainObject;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Messhall.Domain.Permission.BusinessObjects
{
    public class RolePermissionEntity : EntityBoBase
    {
        #region 成员变量

        /// <summary>
        /// 角色Id
        /// </summary>
        public Guid RoleKeyId { get; set; }

        /// <summary>
        /// 权限Id
        /// </summary>
        public Guid PermissionKeyId { get; set; }

        #endregion
    }

    public class RolePermission : BoBase, IAggregateRoot
    {
        private RolePermissionEntity SelfEntity
        {
            get { return Entity as RolePermissionEntity; }
            set { this.Entity = value; }
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="entity"></param>
        public RolePermission(Guid roleKeyId, Guid permissionKeyId)
        {
            this.SelfEntity = new()
            {
                RoleKeyId = roleKeyId,
                PermissionKeyId = permissionKeyId
            };
        }

        public RolePermission(RolePermissionEntity entity)
        {
            this.SelfEntity = entity;
        }

        public Guid GetRoleKeyId()
        {
            return this.SelfEntity.RoleKeyId;
        }

        public void SetRoleKeyId(Guid roleKeyId)
        {
            this.SelfEntity.RoleKeyId = roleKeyId;
        }
        
        public Guid GetPermissionKeyId()
        {
            return this.SelfEntity.PermissionKeyId;
        }

        public void SetPermissionKeyId(Guid permissionKeyId)
        {
            this.SelfEntity.PermissionKeyId = permissionKeyId;
        }
    }
}